package com.warm.pump.module.sys.service.impl;

import com.warm.pump.frame.gen.bean.PageBean;
import com.warm.pump.module.sys.bean.po.gen.DictGroup;
import com.warm.pump.module.sys.dao.gen.DictGroupDao;
import com.warm.pump.module.sys.service.IDictGroupService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.annotation.CacheConfig;
import org.springframework.cache.annotation.CacheEvict;
import org.springframework.cache.annotation.CachePut;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;


@Service("DictGroupService")
@CacheConfig(cacheNames = "DictGroup")
public class DictGroupServiceImpl implements IDictGroupService {
	@Autowired
	private DictGroupDao dictGroupDao;

	@Override
	public DictGroup queryObject(Long  id){
		return dictGroupDao.selectByPrimaryKey( id);
	}

	@Cacheable(key = "targetClass + methodName +#p0")
	public DictGroup queryObject(Map<String, Object> map){
		return dictGroupDao.selectByMap( map);
	}
	
	@Override
	public List<DictGroup> queryList(Map<String, Object> map){
		return dictGroupDao.getListByMap(map);
	}

    @Override
    public PageBean getPageBeanByMap(Map map,int pageNo,int pageSize) {
		return dictGroupDao.getPageBeanByMap(map, pageNo, pageSize);
    }


	@Override
	public int queryTotal(Map<String, Object> map){
		return dictGroupDao.countTotalByMap(map);
	}
	
	@Override
	public void save(DictGroup dictGroup){
		dictGroupDao.insertSelective(dictGroup);
	}
	
	@Override
	@CacheEvict(allEntries=true)
	public void update(DictGroup dictGroup){
		dictGroupDao.updateByPrimaryKeySelective(dictGroup);
	}
	
	@Override
	@CacheEvict(allEntries=true)
	public void delete(Long  id){
		dictGroupDao.deleteByPrimaryKey(id);
	}

	@Override
	@CacheEvict(allEntries=true)
	public void delete(Map<String, Object>  map){
	dictGroupDao.deleteByMap(map);
	}
	
	@Override
	@CacheEvict(allEntries=true)
	public void deleteBatch(Long[]  ids){
		Map<String, Object> map = new HashMap<>();
		map.put("id_in",ids);
		dictGroupDao.deleteByMap(map);
	}
	
}
